package ufpr.mestrado.ais.util;

import java.io.BufferedWriter;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStreamWriter;

import jmetal.base.SolutionSet;
import jmetal.util.Configuration;

public class PrintAndreFile {

	public void printObjectivesToTchebycheff(String path,
			final SolutionSet[] solutionSets) {
		try {

			/* Open the file */
			FileOutputStream fos = new FileOutputStream(path);
			OutputStreamWriter osw = new OutputStreamWriter(fos);
			BufferedWriter bw = new BufferedWriter(osw);

			for (SolutionSet solutionSet : solutionSets) {

				for (int i = 0; i < solutionSet.size(); i++) {
					bw.write(solutionSet.get(i).toString());
					bw.newLine();
				}
				bw.newLine();

			}
			/* Close the file */
			bw.close();

		} catch (IOException e) {
			Configuration.logger_.severe("Error acceding to the file");
			e.printStackTrace();
		}
	}

}
